﻿using UnityEngine;

public class TestTreeSearch : MonoBehaviour
{
    [ContextMenu("Test")]
    void Test()
    {
        Game game = new Game();
        game.Start();

        MonteCarloTreeSearch mcts = new MonteCarloTreeSearch();
        while (!game.m_GameOver)
        {
            int startTime = System.DateTime.Now.Second * 1000 + System.DateTime.Now.Millisecond;
            mcts.StartNew(game, game.m_CurrentPlayer);
            for (int i = 0; i < 1; i++)
            {
                mcts.TreeSearchIteration();
            }
            Vector2Int placePos = mcts.MakeDecision();
            game.Step(placePos);
            Debug.Log($"{game.m_CurrentPlayer} place at {placePos}");
            int time = System.DateTime.Now.Second * 1000 + System.DateTime.Now.Millisecond - startTime;
            Debug.Log($"cost time: {time}ms");
        }
        Debug.Log($"{game.m_Winner} win");
    }
}